/*
 * File:   CompressorTest.cpp
 * Author: Luis
 *
 * Created on 04-abr-2013, 1:30:37
 */

#include <cstring>
#include "CompressorTest.h"
#include "../../src/Compressor/Compressor.h"
#include "../../src/utils/Utils.h"

using namespace zipUtils;

CPPUNIT_TEST_SUITE_REGISTRATION(CompressorTest);

char* path;
FILE* input;
size_t fileSize;
char* buffer;
FILE* fExpected;
char* expected;
size_t bufferSize;

CompressorTest::CompressorTest() {
}

CompressorTest::~CompressorTest() {
}

void CompressorTest::setUp() {
    path = "tests/compressor/input.txt";
    input = fopen(path, "r");
    fileSize = calculateSize(input);
    size_t bufferSize = 30 + strlen("input.txt") + fileSize;
    buffer = (char*) malloc(bufferSize * sizeof(char));
    fExpected = fopen("tests/compressor/resultExpected.txt", "r");
    expected = (char*) malloc(calculateSize(fExpected));
}

void CompressorTest::tearDown() {
    fclose(input);
    fclose(fExpected);
    free(buffer);
    free(expected);
}

void CompressorTest::testBuildFileHeader() {
    char* fileName = "input.txt";
    short compressionMethod = 0;
    Compressor* compressor = new Compressor();;
 //   compressor->buildFileHeader(path, fileName, compressionMethod, buffer, bufferSize);
    delete compressor;
    
    for (int i = 0; i < bufferSize; i++)
    {
        CPPUNIT_ASSERT(buffer[i] == expected[i]);
    }
}
